home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
parcs
/
parcs.lha
/
sample
/
5house
next >
Wrap
Text File
|
1992-06-08
|
657b
|
27 lines
defdomain from1to5 int{1..5}.
houses([N1,N2,N3,N4,C5,C1,C2,C3,C4,C5,P1,P2,P3,P4,P5,A1,A2,A3,A4,A5,D1,D2,D3,D4,D5]) :-
from1to5(N1,N2,N3,N4,C5,C1,C2,C3,C4,C5,P1,P2,P3,P4,P5,A1,A2,A3,A4,A5,D1,D2,D3,D4,D5),
N1=C2,N2=A1,N3=P1,N4=D3,N5=1,D5=3,P3=D1,C1=D4,P5=A4,P2=C3,
C1=C5+1,
plusorminus1(A3,P4),
plusorminus1(A5,P2),
plusorminus1(1,C4),
alldif([N1,N2,N3,N4,N5]),
alldif([C1,C2,C3,C4,C5]),
alldif([P1,P2,P3,P4,P5]),
alldif([A1,A2,A3,A4,A5]),
alldif([D1,D2,D3,D4,D5]).
plusorminus1(X,Y) :- X = Y-1.
plusorminus1(X,Y) :- X = Y+1.
alldif([]).
alldif([A|X]) :- different(A,X),alldif(X).
different(A,[]).
different(A,[B|X]) :- A!=B,different(A,X).